﻿using LimaLims.Application.Service.Base.Dto;
using LimaLims.Core;
using LimaLims.Core.Entity.Basic;
using LimaLims.Core.Entity.TestCenter;
using LimaLims.Core.Enum;
using LimaLims.Core.Util;
using Microsoft.EntityFrameworkCore;

namespace LimaLims.Application.Service.TestCenter.Dto
{
    /// <summary>
    /// 不良品处理DTO
    /// </summary>
    public class RejectDealOutput : BaseDto
    {
        /// <summary>
        /// 试验任务ID
        /// </summary>
        public long ExperimentTaskId { get; set; }

        /// <summary>
        /// 处理单编号
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 任务编号
        /// </summary>
        public string TaskCode { get; set; }

        /// <summary>
        /// 任务类型
        /// </summary>
        public ExperimentType TaskType { get; set; }

        /// <summary>
        /// 任务类型文本
        /// </summary>
        public string TaskTypeText => TaskType.GetDescription();

        /// <summary>
        /// 试验对象ID
        /// </summary>
        public long TargetId { get; set; }

        /// <summary>
        /// 试验对象编号
        /// </summary>
        public string TargetCode { get; set; }

        /// <summary>
        /// 试验对象名称
        /// </summary>
        public string TargetName { get; set; }

        /// <summary>
        /// 班组名称
        /// </summary>
        public string TeamName { get; set; }

        /// <summary>
        /// 试验员
        /// </summary>
        public string ExperimentUserName { get; set; }

        /// <summary>
        /// 试验开始时间
        /// </summary>
        public DateTime ActualStartTime { get; set; }

        /// <summary>
        /// 试验结束时间
        /// </summary>
        public DateTime ActualEndTime { get; set; }

        /// <summary>
        /// 是否需要评审
        /// </summary>
        public bool? IsMRBAdvice { get; set; }

        /// <summary>
        /// 不良品处理建议
        /// </summary>
        public string RejectAdvice { get; set; }

        /// <summary>
        /// MRB评审建议
        /// </summary>
        public string MRBAdvice { get; set; }

        /// <summary>
        /// 最终判定结果
        /// </summary>
        public string Result { get; set; }

        /// <summary>
        /// 处理人员
        /// </summary>
        public string DealUser { get; set; }

        /// <summary>
        /// 处理时间
        /// </summary>
        public DateTime? DealTime { get; set; }

        /// <summary>
        /// 不良品处理单状态
        /// </summary>
        public RejectDealStatus Status { get; set; }

        /// <summary>
        /// 不良品处理单状态文本
        /// </summary>
        public string StatusText => this.Status.GetDescription();
    }

    public class AddRejectDealInput:BaseDto
    {
        /// <summary>
        /// 处理单编号
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 试验任务ID
        /// </summary>
        public long ExperimentTaskId { get; set; }

        public ICollection<RejectItemInput> Items { get; set; }
    }

    /// <summary>
    /// 编辑不良品处理DTO
    /// </summary>
    public class EditRejectDealInput
    {
        /// <summary>
        /// 单据Id
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 处理时间
        /// </summary>
        public DateTime DealTime { get; set; }

        /// <summary>
        /// 处理人员
        /// </summary>
        public string DealUser { get; set; }

        /// <summary>
        /// 不良品处理建议
        /// </summary>
        public string RejectAdvice { get; set; }

        /// <summary>
        /// 是否需要MRB评审
        /// </summary>
        public bool IsMRBAdvice { get; set; }

        /// <summary>
        /// MRB评审建议
        /// </summary>
        public string MRBAdvice { get; set; }

        /// <summary>
        /// 最终判定结果
        /// </summary>
        public string Result { get; set; }
    }

    /// <summary>
    /// 详细信息
    /// </summary>
    public class RejectDealDetail:RejectDealOutput
    {
        public ICollection<RejectItem> Items { get; set; }
    }

    /// <summary>
    /// 不良品处理分页
    /// </summary>
    public class RejectDealPageInput : PageInputBase
    {
        /// <summary>
        /// 处理单编号
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 任务编号
        /// </summary>
        public string TaskCode { get; set; }

        /// <summary>
        /// 是否需要评审
        /// </summary>
        public bool? IsMRBAdvice { get; set; }

        /// <summary>
        /// 不良品处理单状态
        /// </summary>
        public RejectDealStatus Status { get; set; }
    }
}
